var mongoose = require('mongoose')
var Schema = mongoose.Schema;

var contentSchema = new Schema({
    "msg": {
        type: String,
    },
    "timeStamp": {
        type: Number
    },
    "username": {
        type: String
    }
})

var chatSchema = new Schema({
    "username": {
        type: String,
        require: true
    },
    "room_id": {
        type: String,
        required: true
    },
    "timeStamp": {
        type: Number
    },
    "history": {
        type: [contentSchema],
    },
});
// model的一个参数是DB的一个Schema
module.exports = mongoose.model('Chats', chatSchema);